using System;
using System.Collections.Generic;
using System.ByteBuffer;
using tools;

namespace Zjh
{
    /// <summary>
    /// generate by msg tool
    /// 玩家座位信息
    /// </summary>
	public class SeatInfo : Dto
	{
		//玩家id
		public long playerId;
		//微信昵称
		public String nickName;
		//性别
		public int sex;
		//头像地址
		public String icon;
		//积分
		public long cedit;
		//0:离线,非0:在线
		public int online;
		//座位号
		public int order;
		//0:没有准备,非0:准备
		public int ready;
		//下注和比牌的次数
		public int optNum;
		//ip
		public String ip;
		//是否看过牌(0:没看,非0:看)
		public int seeCard;
		//看过牌才有值
		public List<int> cards = new List<int>();
		
		//是否看弃牌(0:没弃,非0:弃)
		public int discard;
		//是否输(0:没输,非0:输)
		public int lose;
		//是否玩过游戏(0:没玩过,非0:玩过)
		public int gamed;

        public SeatInfo() { }

        public SeatInfo(long playerId, String nickName, int sex, String icon, long cedit, int online, int order, int ready, int optNum, String ip, int seeCard, int discard, int lose, int gamed)
        {
            this.playerId = playerId;
            this.nickName = nickName;
            this.sex = sex;
            this.icon = icon;
            this.cedit = cedit;
            this.online = online;
            this.order = order;
            this.ready = ready;
            this.optNum = optNum;
            this.ip = ip;
            this.seeCard = seeCard;
            this.discard = discard;
            this.lose = lose;
            this.gamed = gamed;
        }

        
		public void write(object obj)
		{
			ByteBuffer b = obj as ByteBuffer;
			b.PushLong(playerId);
			b.PushString(nickName);
			b.PushInt(sex);
			b.PushString(icon);
			b.PushLong(cedit);
			b.PushInt(online);
			b.PushInt(order);
			b.PushInt(ready);
			b.PushInt(optNum);
			b.PushString(ip);
			b.PushInt(seeCard);
			b.PushInt(cards.Count);

			foreach (var element in cards)
			{
				b.PushInt(element);
				
			}
			b.PushInt(discard);
			b.PushInt(lose);
			b.PushInt(gamed);
			
		}

	    public void read(object obj)
		{
		    MyConverter b = obj as MyConverter;
			playerId = b.toInt64();
			nickName = b.toString();
			sex = b.toInt32();
			icon = b.toString();
			cedit = b.toInt64();
			online = b.toInt32();
			order = b.toInt32();
			ready = b.toInt32();
			optNum = b.toInt32();
			ip = b.toString();
			seeCard = b.toInt32();
			int cards_length = b.toInt32();
			for (int i = 0; i < cards_length; ++i)
			{
				cards.Add(b.toInt32());
				
			}
			discard = b.toInt32();
			lose = b.toInt32();
			gamed = b.toInt32();
			
		}

	}
}